import allure
from appium.webdriver.common.appiumby import AppiumBy

from .contact_page import ContactPage
from ..base.base import Base


class MainPage(Base):
    __CONTACT_BUTTON = (AppiumBy.XPATH, "//*[@text='通讯录']")

    @allure.step("点击通讯录按钮，进行通讯录界面")
    def goto_contact(self):
        self.find_ele(self.__CONTACT_BUTTON).click()
        image_path = self.screenshot()
        allure.attach.file(image_path, name="点击通讯录按钮", attachment_type=allure.attachment_type.PNG)
        return ContactPage(self.driver)
